package hotel.base.oversea.utils;

import cn.hutool.core.util.StrUtil;
import hotel.base.oversea.constant.enums.MtHotelOrderCheckCodeEnums;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;

import java.util.*;
import java.util.concurrent.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 字符串处理常用功能
 */
@SuppressWarnings({"rawtypes", "unchecked"})
@Slf4j
public class StringUtil {
    /**
     * 字符串中包含中文的表达式
     */
    private static Pattern chinaPattern = Pattern.compile("[\u4e00-\u9fa5]");


    private static Map uuidMap = new HashMap();


    /**
     * private constructor,cann't be instantiated by other class 私有构造函数方法防止被实例化
     */
    private StringUtil() {
    }

    @Deprecated
    public static boolean isNotNullAndBlank(Object str) {
        return !isBlank(str);
    }

    @Deprecated
    public static boolean isNullOrBlank(Object str) {
        return isBlank(str);
    }

    public static String replaceBlank(String str) {
        String dest = "";
        if (str!=null) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(str);
            dest = m.replaceAll("");
        }
        return dest;
    }


    /**
     * @param str
     * @return
     * @todo 判断字符串是空或者空白
     */
    public static boolean isNotBlank(Object str) {
        return !isBlank(str);
    }

    public static Integer timestampIndexId(Long timestamp, RedisTemplate redisTemplate) {
        Integer synId = 1000;
        try {
            Long size = 0L;
            size = getTimestampIndexPopSize(size, timestamp, redisTemplate);
            if (0 == size) {
                for (int i = 1001; i < 1051; i++) {
                    redisTemplate.opsForList().leftPush("this_syn_id_for_notify_log" + timestamp, i);
                }
                redisTemplate.expire("this_syn_id_for_notify_log" + timestamp, 5, TimeUnit.SECONDS);
                return getTimestampIndexPop(synId, timestamp, redisTemplate);
            } else {
                return getTimestampIndexPop(synId, timestamp, redisTemplate);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return synId;
    }

    /**
     * 携程获取很好办订单电话
     * 20210507
     * 携程项目一组
     * 售前：18650009897
     * 售后：13459211839
     * 13062448468
     *
     * 携程项目二组
     * 13365924708（主卡）
     * 13348373858
     * 13394047378
     * --210706
     * 13365924708
     * 13394047378
     * 19521724468
     *
     * --0707
     * 13365924708
     * 13394047378
     * 17350005718
     *
     * 飞猪项目组
     * 13074841668
     *
     * @param redisTemplate
     * @return
     */
    public static String getQueuePhone(RedisTemplate redisTemplate) {
        String re = "";
        try {
            String queueKey = "order_phone_random";
            Long size = redisTemplate.opsForList().size(queueKey);
            if (size == 0) {
                List<String> pList = new ArrayList<>();
                String phones = "";
                if (null != redisTemplate.opsForValue().get("hhb_service_phones_json")) {
                    //逗号隔开服务电话字符串 "13062448468,18650009897,13925552387,13074841668"
                    phones = (String) redisTemplate.opsForValue().get("hhb_service_phones_json");
                }
                if (!phones.equals("")) {
                    log.info("getQueuePhone 缓存存在hhb客服电话：" + phones);
                    for (int i = 0; i < phones.split(",").length; i++) {
                        String p = phones.split(",")[i];
                        pList.add(p);
                    }
                } else {
                    pList.add("13365924708");//pList.add("18516352057"); version qiuyy 2021-01-11 暂停
                    pList.add("17350005718");//售后 13074841668    13062448468   售前13925552387   18650009897
                    pList.add("13394047378");
                }

                for (String s : pList) {
                    redisTemplate.opsForList().rightPush(queueKey, s);
                }
                re = (String) redisTemplate.opsForList().leftPop(queueKey);
                log.info("getQueuePhone 1order_phone_random 取出后，队列size ：" + redisTemplate.opsForList().size(queueKey));
                if (!ObjectUtils.isEmpty(re)) {
                    redisTemplate.opsForList().rightPush(queueKey, re);//用一个放一个
                    log.info("getQueuePhone 1order_phone_random 取一个放一个，队列size ：" + redisTemplate.opsForList().size(queueKey));
                } else {
                    log.info("getQueuePhone 1order_phone_random 当前取出为空");
                }

            } else {
                re = (String) redisTemplate.opsForList().leftPop(queueKey);
                log.info("getQueuePhone 2order_phone_random 取出后，队列size ：" + redisTemplate.opsForList().size(queueKey));
                if (!ObjectUtils.isEmpty(re)) {
                    redisTemplate.opsForList().rightPush(queueKey, re);//用一个放一个
                    log.info("getQueuePhone 2order_phone_random 取一个放一个，队列size ：" + redisTemplate.opsForList().size(queueKey));
                } else {
                    log.info("getQueuePhone 2order_phone_random 当前取出为空");
                }

            }
        } catch (Exception e) {
            re = "13062448468";//异常时默认
            log.info("获取队列手机号异常：" + e.getMessage());
            e.printStackTrace();
        }
        return re;
    }




    /**
     * 飞猪获取很好办订单电话
     *
     * @param redisTemplate
     * @return
     */
    public static String getFpQueuePhone(RedisTemplate redisTemplate) {
        String re = "";
        try {
            String key = "fp_order_phone_random";
            Long size = redisTemplate.opsForList().size(key);
            if (size == 0) {
                List<String> pList = new ArrayList<>();
                String phones = "";
                if (null != redisTemplate.opsForValue().get("fp_hhb_service_phones_json")) {//逗号隔开服务电话字符串
                    phones = (String) redisTemplate.opsForValue().get("fp_hhb_service_phones_json");
                }
                if (!phones.equals("")) {
                    log.info("getQueuePhone 缓存存在hhb客服电话：" + phones);
                    for (int i = 0; i < phones.split(",").length; i++) {
                        String p = phones.split(",")[i];
                        pList.add(p);
                    }
                } else {
                    pList.add("18521757201");
                }

                for (String s : pList) {
                    redisTemplate.opsForList().rightPush(key, s);
                }
                re = (String) redisTemplate.opsForList().leftPop(key);
                log.info("飞猪getQueuePhone 1order_phone_random 取出后，队列size ：" + redisTemplate.opsForList().size(key));
                if (!ObjectUtils.isEmpty(re)) {
                    redisTemplate.opsForList().rightPush(key, re);//用一个放一个
                    log.info("飞猪getQueuePhone 1order_phone_random 取一个放一个，队列size ：" + redisTemplate.opsForList().size(key));
                } else {
                    log.info("飞猪getQueuePhone 1order_phone_random 当前取出为空");
                }

            } else {
                re = (String) redisTemplate.opsForList().leftPop(key);
                log.info("飞猪getQueuePhone 2order_phone_random 取出后，队列size ：" + redisTemplate.opsForList().size(key));
                if (!ObjectUtils.isEmpty(re)) {
                    redisTemplate.opsForList().rightPush(key, re);//用一个放一个
                    log.info("飞猪getQueuePhone 2order_phone_random 取一个放一个，队列size ：" + redisTemplate.opsForList().size(key));
                } else {
                    log.info("飞猪getQueuePhone 2order_phone_random 当前取出为空");
                }

            }
        } catch (Exception e) {
            log.info("飞猪获取队列手机号异常：" + e.getMessage());
            e.printStackTrace();
        }
        if (ObjectUtils.isEmpty(re)) {
            log.error("飞猪getQueuePhone 获取到phone为空 异常");
            return getFpHhbServicePhoneRandom(redisTemplate);
        }
        return re;
    }

    /**
     * 获取很好办订单电话
     *
     * @param redisTemplate
     * @return
     */
    public static String getFpHhbServicePhoneRandom(RedisTemplate redisTemplate) {
        log.info("飞猪进入getHhbServicePhoneRandom");
        Integer exiIndex = (Integer) redisTemplate.opsForValue().get("getFpHhbServicePhoneRandom_last_v");
        String phones = "";
        if (null != redisTemplate.opsForValue().get("fp_hhb_service_phones_json")) {//逗号隔开服务电话字符串
            phones = (String) redisTemplate.opsForValue().get("fp_hhb_service_phones_json");
        }
        Map<Integer, String> mapPhone = new HashMap();
        if (!phones.equals("")) {
            log.info("飞猪缓存存在hhb客服电话：" + phones);
            for (int i = 0; i < phones.split(",").length; i++) {
                String p = phones.split(",")[i];
                mapPhone.put(i, p);
            }
        } else {
            //初始默认
            mapPhone.put(0, "18521757201");
        }
        if (null != exiIndex) {
            mapPhone.remove(exiIndex);
        }
        int max = mapPhone.size();
        String servicePhone = null;
        if (max > 0) {
            try {
                int r = new Random().nextInt(max);
                int j = 0;
                for (Map.Entry e : mapPhone.entrySet()) {
                    if (j == r) {
                        servicePhone = mapPhone.get(e.getKey());
                        redisTemplate.opsForValue().set("getFpHhbServicePhoneRandom_last_v", e.getKey(), 23, TimeUnit.HOURS);
                        if (ObjectUtils.isEmpty(servicePhone)) {
                            servicePhone = "18521757201";
                            log.info("飞猪服务电话异常，当前默认返回18521757201");
                        }
                    }
                    j++;
                }

            } catch (Exception e) {
                log.error("飞猪服务电话异常，e=" + e.getMessage());
                e.printStackTrace();
            }
        }
        if (ObjectUtils.isEmpty(servicePhone)) {
            servicePhone = "18521757201";
            log.info("飞猪服务电话异常，当前默认返回18521757201");
        }
        return servicePhone;
    }

    /**
     * 获取指定时间戳+随机数
     *
     * @return
     */
    public static String getTimestampRandom(Long timestamp) {
        String t = "";
        synchronized (t) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            t = String.valueOf(timestamp) + getFourRandom();
        }
        return t;
    }


    public static Long getTimestampIndexPopSize(Long size, Long timestamp, RedisTemplate redisTemplate) {
        synchronized (size) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            size = redisTemplate.opsForList().size("this_syn_id_for_notify_log" + timestamp);
        }
        return size;
    }

    public static Integer getTimestampIndexPop(Integer synId, Long timestamp, RedisTemplate redisTemplate) {
        synchronized (synId) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synId = (Integer) redisTemplate.opsForList().rightPop("this_syn_id_for_notify_log" + timestamp);
        }
        return synId;
    }

    public static boolean isBlank(Object str) {
        if (null == str || str.toString().trim().equals("")) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * @param source
     * @param target
     * @return
     * @todo 替换换行、回车、tab符号;\r 换行、\t tab符合、\n 回车
     */
    public static String clearMistyChars(String source, String target) {
        return source.replaceAll("\r", target).replaceAll("\t", target).replaceAll("\n", target);
    }

    /**
     * @param sourceStr
     * @return
     * @todo 返回第一个字符大写，其余保持不变的字符串
     */
    public static String firstToUpperCase(String sourceStr) {
        if (isBlank(sourceStr)) {
            return sourceStr;
        }
        if (sourceStr.length() == 1) {
            return sourceStr.toUpperCase();
        }
        return sourceStr.substring(0, 1).toUpperCase().concat(sourceStr.substring(1));
    }

    /**
     * @param sourceStr
     * @return
     * @todo 返回第一个字符小写，其余保持不变的字符串
     */
    public static String firstToLowerCase(String sourceStr) {
        if (isBlank(sourceStr)) {
            return sourceStr;
        }
        if (sourceStr.length() == 1) {
            return sourceStr.toUpperCase();
        }
        return sourceStr.substring(0, 1).toLowerCase().concat(sourceStr.substring(1));
    }

    /**
     * @param sourceStr
     * @return
     * @todo 返回第一个字符大写，其余保持不变的字符串
     */
    public static String firstToUpperOtherToLower(String sourceStr) {
        if (isBlank(sourceStr)) {
            return sourceStr;
        }
        if (sourceStr.length() == 1) {
            return sourceStr.toUpperCase();
        }
        return sourceStr.substring(0, 1).toUpperCase().concat(sourceStr.substring(1).toLowerCase());
    }

    /**
     * @param source
     * @param pattern
     * @return
     * @todo 在不分大小写情况下字符所在位置
     */
    public static int indexOfIgnoreCase(String source, String pattern) {
        if (source == null || pattern == null) {
            return -1;
        }
        return source.toLowerCase().indexOf(pattern.toLowerCase());
    }

    /**
     * @param source
     * @param length
     * @return
     * @todo 左补零
     */
    public static String addLeftZero2Len(String source, int length) {
        return addSign2Len(source, length, 0, 0);
    }

    /**
     * @param source
     * @param length
     * @return
     * @todo 用空字符给字符串补足不足指定长度部分
     */
    public static String addRightBlank2Len(String source, int length) {
        return addSign2Len(source, length, 1, 1);
    }

    /**
     * @param source
     * @param length
     * @param flag
     * @param leftOrRight
     * @return
     */
    private static String addSign2Len(String source, int length, int flag, int leftOrRight) {
        if (source == null || source.length() >= length) {
            return source;
        }
        int addSize = length - source.length();
        StringBuilder addStr = new StringBuilder();
        // 右边
        if (leftOrRight == 1) {
            addStr.append(source);
        }
        String sign = (flag == 1) ? " " : "0";
        for (int i = 0; i < addSize; i++) {
            addStr.append(sign);
        }
        // 左边
        if (leftOrRight == 0) {
            addStr.append(source);
        }
        return addStr.toString();
    }

    /**
     * @param source
     * @param sign
     * @param loopSize
     * @return
     * @todo <b>用特定符号循环拼接指定的字符串</b>
     * @date 2012-7-12 下午10:17:30
     */
    public static String loopAppendWithSign(String source, String sign, int loopSize) {
        if (loopSize == 0) {
            return "";
        }
        if (loopSize == 1) {
            return source;
        }
        StringBuilder result = new StringBuilder(source);
        for (int i = 1; i < loopSize; i++) {
            result.append(sign).append(source);
        }
        return result.toString();
    }

    /**
     * @param source
     * @param sign
     * @param size
     * @param isLeft
     * @todo 补字符(限单字符)
     */
    public static String appendStr(String source, String sign, int size, boolean isLeft) {
        int length = 0;
        StringBuilder addStr = new StringBuilder("");
        String tmpStr = "";
        if (source != null) {
            length = source.length();
            tmpStr = source;
        }
        if (!isLeft) {
            addStr.append(tmpStr);
        }
        for (int i = 0; i < size - length; i++) {
            addStr.append(sign);
        }
        if (isLeft) {
            addStr.append(tmpStr);
        }
        return addStr.toString();
    }

    /**
     * @param beginMarkSign
     * @param endMarkSign
     * @param source
     * @param startIndex
     * @return
     * @todo 查询对称标记符号的位置，startIndex必须是<source.indexOf(beginMarkSign)
     */
    public static int getSymMarkIndex(String beginMarkSign, String endMarkSign, String source, int startIndex) {
        // 判断对称符号是否相等
        boolean symMarkIsEqual = beginMarkSign.equals(endMarkSign) ? true : false;
        int beginSignIndex = source.indexOf(beginMarkSign, startIndex);
        int endIndex = -1;
        if (beginSignIndex == -1) {
            return source.indexOf(endMarkSign, startIndex);
        } else {
            endIndex = source.indexOf(endMarkSign, beginSignIndex + 1);
        }
        int tmpIndex = 0;
        while (endIndex > beginSignIndex) {
            // 寻找下一个开始符号
            beginSignIndex = source.indexOf(beginMarkSign, (symMarkIsEqual ? endIndex : beginSignIndex) + 1);
            // 找不到或则下一个开始符号位置大于截止符号则返回
            if (beginSignIndex == -1 || beginSignIndex > endIndex) {
                return endIndex;
            }
            tmpIndex = endIndex;
            // 开始符号在截止符号前则寻找下一个截止符号
            endIndex = source.indexOf(endMarkSign, (symMarkIsEqual ? beginSignIndex : endIndex) + 1);
            // 找不到则返回
            if (endIndex == -1) {
                return tmpIndex;
            }
        }
        return endIndex;
    }

    /**
     * @param beginMarkSign
     * @param endMarkSign
     * @param source
     * @param startIndex
     * @return
     * @todo 查询对称标记符号的位置
     */
    public static int getSymMarkIndexIgnoreCase(String beginMarkSign, String endMarkSign, String source,
                                                int startIndex) {
        return getSymMarkIndex(beginMarkSign.toLowerCase(), endMarkSign.toLowerCase(), source.toLowerCase(),
                startIndex);
    }

    /**
     * @param source
     * @param regex
     * @return
     * @todo 通过正则表达式判断是否匹配
     */
    public static boolean matches(String source, String regex) {
        return matches(source, Pattern.compile(regex));
    }

    /**
     * @param source
     * @param p
     * @return
     * @todo 通过正则表达式判断是否匹配
     */
    public static boolean matches(String source, Pattern p) {
        return p.matcher(source).find();
    }

    /**
     * @param source
     * @param regex
     * @return
     * @todo 找到匹配的位置
     */
    public static int matchIndex(String source, String regex) {
        return matchIndex(source, Pattern.compile(regex));
    }

    public static int matchIndex(String source, Pattern p) {
        Matcher m = p.matcher(source);
        if (m.find()) {
            return m.start();
        } else {
            return -1;
        }
    }

    public static int matchLastIndex(String source, String regex) {
        return matchLastIndex(source, Pattern.compile(regex));
    }

    public static int matchLastIndex(String source, Pattern p) {
        Matcher m = p.matcher(source);
        int matchIndex = -1;
        while (m.find()) {
            matchIndex = m.start();
        }
        return matchIndex;
    }

    /**
     * @param source
     * @param regex
     * @return
     * @todo 获取匹配成功的个数
     */
    public static int matchCnt(String source, String regex) {
        return matchCnt(source, Pattern.compile(regex));
    }

    /**
     * @param source
     * @param p
     * @return
     * @todo 获取匹配成功的个数
     */
    public static int matchCnt(String source, Pattern p) {
        Matcher m = p.matcher(source);
        int count = 0;
        while (m.find()) {
            count++;
        }
        return count;
    }

    /**
     * @param source
     * @param regex
     * @param beginIndex
     * @param endIndex
     * @return
     * @todo 获取匹配成功的个数
     */
    public static int matchCnt(String source, String regex, int beginIndex, int endIndex) {
        return matchCnt(source.substring(beginIndex, endIndex), Pattern.compile(regex));
    }

    /**
     * @param source
     * @param regex
     * @param order
     * @return
     * @todo 获取字符指定次数的位置
     */
    public static int indexOrder(String source, String regex, int order) {
        int begin = 0;
        int count = 0;
        int index = source.indexOf(regex, begin);
        while (index != -1) {
            if (count == order) {
                return index;
            } else {
                begin = index + 1;
                index = source.indexOf(regex, begin);
            }
            count++;
        }
        return -1;
    }

    /**
     * @param str
     * @return
     * @todo 字符串转ASCII
     */
    public static int[] str2ASCII(String str) {
        char[] chars = str.toCharArray(); // 把字符中转换为字符数组
        int[] result = new int[chars.length];
        for (int i = 0; i < chars.length; i++) {// 输出结果
            result[i] = (int) chars[i];
        }
        return result;
    }

    /**
     * @param source
     * @param regex
     * @param filter
     * @return
     * @todo 切割字符串，排除特殊字符对，如a,b,c,dd(a,c),dd(a,c)不能切割
     */
    public static String[] splitExcludeSymMark(String source, String regex, HashMap filter) {
        if (source == null) {
            return null;
        }
        int regsIndex = source.indexOf(regex);
        if (regsIndex == -1) {
            return new String[]{source};
        }
        if (filter == null || filter.isEmpty()) {
            return source.split(regex);
        } else {
            String[][] filters = new String[filter.size()][2];
            Iterator iter = filter.entrySet().iterator();
            int count = 0;
            String beginSign;
            String endSign;
            int beginSignIndex;
            Map.Entry entry;
            while (iter.hasNext()) {
                entry = (Map.Entry) iter.next();
                beginSign = (String) entry.getKey();
                endSign = (String) entry.getValue();
                beginSignIndex = source.indexOf(beginSign);
                if (beginSignIndex != -1 && source.indexOf(endSign, beginSignIndex + 1) != -1) {
                    filters[count][0] = beginSign;
                    filters[count][1] = endSign;
                    count++;
                }
            }
            // 没有对称符合过滤则直接返回分割结果
            if (count == 0) {
                return source.split(regex);
            }

            ArrayList splitResults = new ArrayList();
            int preRegsIndex = 0;
            int regexLength = regex.length();
            int symBeginIndex = 0;
            int symEndIndex = 0;
            int skipIndex = 0;
            int minBegin = -1;
            int minEndIndex = -1;
            int meter = 0;
            while (regsIndex != -1) {
                // 寻找最前的对称符号
                minBegin = -1;
                minEndIndex = -1;
                meter = 0;
                for (int i = 0; i < count; i++) {
                    symBeginIndex = source.indexOf(filters[i][0], skipIndex);
                    symEndIndex = getSymMarkIndex(filters[i][0], filters[i][1], source, skipIndex);
                    if (symBeginIndex != -1 && symEndIndex != -1 && (meter == 0 || (symBeginIndex < minBegin))) {
                        minBegin = symBeginIndex;
                        minEndIndex = symEndIndex;
                        meter++;
                    }

                }
                // 在中间
                if (minBegin < regsIndex && minEndIndex > regsIndex) {
                    skipIndex = minEndIndex + 1;
                    regsIndex = source.indexOf(regex, minEndIndex + 1);
                } else {
                    // 对称开始符号在分割符号后面或分割符前面没有对称符号或找不到对称符号
                    if (minBegin > regsIndex || minBegin == -1) {
                        splitResults
                                .add(source.substring(preRegsIndex + (preRegsIndex == 0 ? 0 : regexLength), regsIndex));
                        preRegsIndex = regsIndex;
                        skipIndex = preRegsIndex + 1;
                        regsIndex = source.indexOf(regex, preRegsIndex + 1);
                    } // 对称截止符号在分割符前面，向下继续寻找
                    else {
                        skipIndex = minEndIndex + 1;
                    }
                }
                // 找不到下一个分隔符号
                if (regsIndex == -1) {
                    splitResults.add(source.substring(preRegsIndex + (preRegsIndex == 0 ? 0 : regexLength)));
                    break;
                }
            }
            String[] resultStr = new String[splitResults.size()];
            for (int j = 0; j < splitResults.size(); j++) {
                resultStr[j] = (String) splitResults.get(j);
            }
            return resultStr;
        }
    }

    /**
     * @param source
     * @param firstIsUpperCase
     * @return
     * @todo 将字符串转换成驼峰形式
     */
    public static String toHumpStr(String source, boolean firstIsUpperCase) {
        if (StringUtil.isBlank(source)) {
            return source;
        }
        String[] humpAry = source.split("\\_");
        String cell;
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < humpAry.length; i++) {
            cell = humpAry[i];
            // 全大写或全小写
            if (cell.toUpperCase().equals(cell)) {
                result.append(firstToUpperOtherToLower(cell));
            } else {
                result.append(firstToUpperCase(cell));
            }
        }
        // 首字母变大写
        if (firstIsUpperCase) {
            return firstToUpperCase(result.toString());
        } else {
            return firstToLowerCase(result.toString());
        }
    }

    /**
     * @param value
     * @param preLength
     * @param tailLength
     * @param maskStr
     * @return
     * @todo 通过特殊符号对字符进行安全模糊化处理
     */
    public static String secureMask(Object value, int preLength, int tailLength, String maskStr) {
        if (value == null) {
            return null;
        }
        String tmp = value.toString();
        if (tmp.length() <= preLength + tailLength) {
            return tmp;
        } else {
            return tmp.substring(0, preLength).concat(maskStr == null ? "***" : maskStr)
                    .concat(tmp.substring(tmp.length() - tailLength));
        }
    }

    /**
     * @param str
     * @return
     * @todo 判断字符串中是否包含中文
     */
    public static boolean hasChinese(String str) {
        if (chinaPattern.matcher(str).find()) {
            return true;
        }
        return false;
    }

    /**
     * @param source
     * @param split
     * @return
     * @todo 驼峰形式字符用分割符号链接, example:humpToSplitStr("organInfo","_") result:organ_Info
     */
    public static String humpToSplitStr(String source, String split) {
        if (source == null) {
            return null;
        }
        char[] chars = source.trim().toCharArray();
        StringBuilder result = new StringBuilder();
        int charInt;
        int uperCaseCnt = 0;
        for (int i = 0; i < chars.length; i++) {
            charInt = chars[i];
            if (charInt >= 65 && charInt <= 90) {
                uperCaseCnt++;
            } else {
                uperCaseCnt = 0;
            }
            // 连续大写
            if (uperCaseCnt == 1 && i != 0) {
                result.append(split);
            }
            result.append(Character.toString(chars[i]));
        }
        return result.toString();
    }

    /**
     * @param template
     * @param args
     * @return
     * @todo 填充args参数
     */
    public static String fillArgs(String template, Object... args) {
        if (template == null || (args == null || args.length == 0)) {
            return template;
        }
        for (Object arg : args) {
            template = template.replaceFirst("\\$?\\{\\s*\\}", arg == null ? "null" : arg.toString());
        }
        return template;
    }

    /**
     * 指定字符长度，不足则补充<br/>
     * 默认：不足不补充
     *
     * @param src
     * @param limit
     * @return
     */
    public static String getLMTString(Object src, int limit) {
        return getLMTString(src, limit, true, true, null);
    }

    /**
     * 指定字符长度，不足则补充<br/>
     * 默认:补充在最后
     *
     * @param src
     * @param limit      限制的长度
     * @param supplement 不足补充
     * @return
     */
    public static String getLMTString(Object src, int limit, String supplement) {
        return getLMTString(src, limit, true, true, supplement);
    }

    /**
     * 指定字符长度，不足则补充
     *
     * @param src
     * @param limit
     * @param isBack     是否补充在最后
     * @param supplement
     * @return
     */
    public static String getLMTString(Object src, int limit, boolean isBack, String supplement) {
        return getLMTString(src, limit, true, isBack, supplement);
    }

    /**
     * 指定字符长度，不足则补充,超过则截取
     *
     * @param src
     * @param limit
     * @param frontBegin 若超过,是否从前往后截取
     * @param isBack
     * @param supplement
     * @return
     */
    public static String getLMTString(Object src, int limit, boolean frontBegin, boolean isBack, String supplement) {
        if (src == null) {
            return null;
        }
        String target = src.toString();
        int diffValue = target.length() - limit;
        if (diffValue == 0) {
            return target;
        } else if (diffValue > 0) {
            return frontBegin ? target.substring(0, limit) : target.substring(diffValue, target.length());
        }
        supplement = supplement == null ? "" : supplement;
        if (supplement.equals("")) {
            return target;
        }
        if (isBack) {
            do {
                target += supplement;
            } while (target.length() < limit);
        } else {
            do {
                target = supplement + target;
            } while (target.length() < limit);
        }
        return target.length() == limit ? target : target.substring(0, limit);
    }

    /**
     * 获取uuid
     *
     * @return
     */
    public static String getUUID() {
        String uuid = "";
        synchronized (uuid) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
//			uuid = (UUID.randomUUID().toString()).replace("-", "");
//			uuid =uuid + getFourRandom();
            UUID uuidObj = UUIDUtils.create();
            uuid = (uuidObj.toString()).replace("-", "") + getFourRandom();
        }
        return uuid;
    }


    /**
     * 获取字符串,通过符号拼接
     *
     * @param list
     */
    public static String getStringByList(List<Integer> list, String delimilter) {
        StringJoiner joiner = new StringJoiner(",");
        for (Integer value : list) {
            joiner.add(String.valueOf(value));
        }
        return joiner.toString();
    }

    /**
     * 获取字符串,通过符号拼接
     *
     * @param list
     */
    public static String getStringByArray(Integer[] list, String s) {
        StringJoiner joiner = new StringJoiner(",");
        for (Integer value : list) {
            joiner.add(String.valueOf(value));
        }
        return joiner.toString();
    }

    /**
     * 产生4位随机数(0000-9999)
     *
     * @return 4位随机数
     */
    public static String getFourRandom() {
        Random random = new Random();
        String fourRandom = random.nextInt(10000) + "";
        int randLength = fourRandom.length();
        if (randLength < 4) {
            for (int i = 1; i <= 4 - randLength; i++)
                fourRandom = "0" + fourRandom;
        }
        return fourRandom;
    }


    public static String getCH(int input) {
        String sd = "";
        switch (input) {
            case 1:
                sd = "一";
                break;
            case 2:
                sd = "二";
                break;
            case 3:
                sd = "三";
                break;
            case 4:
                sd = "四";
                break;
            case 5:
                sd = "五";
                break;
            case 6:
                sd = "六";
                break;
            case 7:
                sd = "七";
                break;
            case 8:
                sd = "八";
                break;
            case 9:
                sd = "九";
                break;
            default:
                sd = "多";
                break;
        }
        return sd;
    }


    public static String converMtId(String str, Integer index) {
        return str.substring(index);
    }

    /**
     * <H1>转换美团ID</H1>
     *
     * @param str 实体对象
     * @return java.lang.String
     * @author HuangT
     * @Date 2020/11/24 20:07
     */
    public static String changeMtId(String str) {
        if(StrUtil.isNotBlank(str)) {
            int i = str.indexOf("_");
            return str.substring(i + 1);
        } else {
            return null;
        }
    }


    /**
     * @author: lmf
     * @date: 2020/8/24 17:01
     */


    public static void main(String[] arg) throws Exception {
        //测试发布
        //String s = "{\"mtHotelId\":5641133,\"roomDataEntityList\":[{\"goodId\":2085023,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]},{\"goodId\":2085027,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]},{\"goodId\":2085026,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]},{\"goodId\":2085025,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]}]}";
        //String s1 = "{\"mtHotelId\":5641133,\"roomDataEntityList\":[{\"goodId\":2085023,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]},{\"goodId\":2085027,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]},{\"goodId\":2085026,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]},{\"goodId\":2085025,\"goodInventory\":1,\"roomStatusInventorys\":[{\"date\":\"2020-08-24\",\"goodStatus\":1},{\"date\":\"2020-08-25\",\"goodStatus\":1},{\"date\":\"2020-08-26\",\"goodStatus\":1},{\"date\":\"2020-08-27\",\"goodStatus\":1},{\"date\":\"2020-08-28\",\"goodStatus\":1},{\"date\":\"2020-08-29\",\"goodStatus\":1},{\"date\":\"2020-08-30\",\"goodStatus\":1},{\"date\":\"2020-08-31\",\"goodStatus\":1},{\"date\":\"2020-09-01\",\"goodStatus\":1},{\"date\":\"2020-09-02\",\"goodStatus\":1},{\"date\":\"2020-09-03\",\"goodStatus\":1},{\"date\":\"2020-09-04\",\"goodStatus\":1},{\"date\":\"2020-09-05\",\"goodStatus\":1},{\"date\":\"2020-09-06\",\"goodStatus\":1},{\"date\":\"2020-09-07\",\"goodStatus\":1},{\"date\":\"2020-09-08\",\"goodStatus\":1},{\"date\":\"2020-09-09\",\"goodStatus\":1},{\"date\":\"2020-09-10\",\"goodStatus\":1},{\"date\":\"2020-09-11\",\"goodStatus\":1},{\"date\":\"2020-09-12\",\"goodStatus\":1},{\"date\":\"2020-09-13\",\"goodStatus\":1},{\"date\":\"2020-09-14\",\"goodStatus\":1},{\"date\":\"2020-09-15\",\"goodStatus\":1},{\"date\":\"2020-09-16\",\"goodStatus\":1},{\"date\":\"2020-09-17\",\"goodStatus\":1},{\"date\":\"2020-09-18\",\"goodStatus\":1},{\"date\":\"2020-09-19\",\"goodStatus\":1},{\"date\":\"2020-09-20\",\"goodStatus\":1},{\"date\":\"2020-09-21\",\"goodStatus\":1},{\"date\":\"2020-09-22\",\"goodStatus\":1}]}]}";
        //System.out.println(s.equals(s1))
        if(0.0 == MtHotelOrderCheckCodeEnums.NO_BOOKING.getCode()) {
            System.out.println(11111);
        }



        //for (int i = 0; i < num.length; i++) {
        //    for (int j = 0; j < num.length; j++) {
        //        if(num[i] < num[j]) {
        //            int n = num[j];
        //            num[j] = num[i];
        //            num[i] = n;
        //        }
        //    }
        //}
        //System.out.println(Arrays.toString(num));

        //String ch = getCH(12);
        //System.out.println(ch);

//		labe:for(int i=0;i<10;i++){
//			System.out.println("i:"+i);
//		  for(int a=0;a<10;a++){
//		  	System.out.println("a:"+a);
//			if(a == 2){
//
//				continue labe;//跳出整个循环
//			}
//
//			  System.out.println("asdasdf:");
//		  }
//
//		}
//		List list =  new ArrayList<>();

//		Map idMap = new HashMap();
//
//		for(int n=0;n<10;n++){
//			for(int i=0;i<100;i++){
//				System.out.println("n---:"+n);
////				String uuid = getFourRandom();
//				String uuid = getUUID();
////				UUID uuidObj = UUIDUtils.create();
////				String uuid = uuidObj.toString();
//				if(uuidMap.size()>0){
//					if(uuidMap.containsKey(uuid)){
//						System.out.println("uuid i="+i+"---:"+uuid + "  idMap.get()"+idMap.get(uuid)+"   time"+ System.currentTimeMillis());
//					}
//				}
//
//				uuidMap.put(uuid,uuid);
//			}
//		}
//		System.out.println("uuidMap---:"+uuidMap);
//
//		Iterator iter = uuidMap.entrySet().iterator();
//		while (iter.hasNext()) {
//		Map.Entry entry = (Map.Entry) iter.next();
//		Object key = entry.getKey();
//		Object val = entry.getValue();
//			System.out.println("key:"+key + "--val:"+val);
//		}

//		UUID uuid = UUIDUtils.random();
//		System.out.println("uuid---:"+uuid.toString());

//		String uuid = getUUID();
//		System.out.println("uuid---:"+uuid);
//		System.out.println("uuid.length()---:"+uuid.length());


        //long lastTime = System.currentTimeMillis();
        //try {
        //	Thread.sleep(1);
        //} catch (InterruptedException e) {
        //	e.printStackTrace();
        //}
        //long nowTime = System.currentTimeMillis();
        //
        //System.out.println("lastTime : "+lastTime + "--  nowTime : " + nowTime);
        //
        //List<String> list = new ArrayList<>();
        //for(int i=0;i<100000;i++){
        //	list.add(String.valueOf(i));
        //}
        //list2Hotel(list,10);


    }

    public static void printString(List<String> list, int nThreads) {
        for (int i = 0; i < list.size(); i++) {
            log.info("{} -------> {}", list.get(i), nThreads);
        }
    }

    public static String list2Hotel(List<String> list, final int nThreads)
            throws Exception {
        if (list == null || list.isEmpty()) {
            return null;
        }
        StringBuffer ret = new StringBuffer();
        long start = System.currentTimeMillis();
        int size = list.size();
        ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
        List<Future<String>> futures = new ArrayList<Future<String>>(nThreads);
        for (int i = 0; i < nThreads; i++) {
            final List<String> subList = list.subList(size / nThreads * i, size / nThreads * (i + 1));
            log.info("subList.size --> {}", subList.size());
            int finalI = i;
            Callable<String> task = new Callable<String>() {
                @Override
                public String call() throws Exception {
                    printString(subList, nThreads);
                    return null;
                }
            };
            futures.add(executorService.submit(task));
            Thread.sleep(100);
        }

        for (Future<String> future : futures) {
            log.info("进入 for (Future<String> future : futures) {} -->");
            log.info("subList.size --> {}", future.get());
//            ret.append(future.get());
        }
        executorService.shutdown();
        while (true) {
            if (executorService.isTerminated()) {
                long time = System.currentTimeMillis() - start;
                System.out.println("[" + DateUtil.getNowTime() + "]:" + "程序结束了，总耗时：" + time + " ms(毫秒)！\n");
                break;
            }
        }
        log.info("ret --> {}", ret.toString());
        return ret.toString();
    }


}
